//
//  XWTableViewCell_b.m
//  网易新闻
//
//  Created by dllo on 15/9/21.
//  Copyright (c) 2015年 Lx. All rights reserved.
//

#import "ZGL24NewsCell_bigPic.h"
#import "ZGL24NewsModel.h"
#import <SDWebImage/UIImageView+WebCache.h>
@interface ZGL24NewsCell_bigPic()
@property(nonatomic, retain)UILabel *title;//标题
@property(nonatomic, retain)UILabel *source;//作者
@property(nonatomic, retain)UIImageView *img;//图片
@property(nonatomic, retain)UIView *back;//背景
@end
@implementation ZGL24NewsCell_bigPic
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _back = [[UIView alloc]init];
        [self.contentView addSubview:_back];
        
        _title = [[UILabel alloc]init];
        _title.numberOfLines = 0;
        [_title sizeToFit];
        [_back addSubview:_title];
        
        _source = [[UILabel alloc]init];
        _source.textColor = [UIColor lightGrayColor];
        _source.font = [UIFont systemFontOfSize:14];
        [_back addSubview:_source];
        
        _img = [[UIImageView alloc]init];
        _img.backgroundColor = [UIColor grayColor];
        [_back addSubview:_img];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.backgroundColor = backColor;
    _back.backgroundColor = foreColor;
    _title.textColor = artiColor;
    _back.frame = CGRectMake(0, 1, Width, (int)120*ScaleX+70);
    _img.frame = CGRectMake((int)10*ScaleX, 10, (int)355*ScaleX, (int)120*ScaleX);
    _title.frame = CGRectMake((int)10*ScaleX, (int)120*ScaleX+20, (int)355*ScaleX, 20);
    _source.frame = CGRectMake((int)10*ScaleX, (int)120*ScaleX+40, (int)355*ScaleX, 20);
}

- (void)setMod:(ZGL24NewsModel *)mod{
    _height = (int)120*ScaleX+80;
    
    _title.text= mod.title;
    if (!mod.source) {
        mod.source = @"";
    }
    _source.text = [[NSString stringWithFormat:@"%@    %@", mod.source, mod.ptime]stringByReplacingOccurrencesOfString:@"$" withString:@""];
    [_img sd_setImageWithURL:mod.imgsrc placeholderImage:[UIImage imageNamed:@"squirrel"]];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
